package com.sangsang.controller;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sangsang.cdc.mapper.TbOrderCapacityCDCMapper;
import com.sangsang.domain.entity.TbOrderCapacity;
import com.sangsang.domain.entity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author liutangqi
 * @date 2025/1/13 15:58
 */
@RestController
public class TestController {
//    @Autowired
//    private UserMapper userMapper;

    @Autowired
    private TbOrderCapacityCDCMapper tbOrderCapacityCDCMapper;

    @GetMapping("/test")
    public String test() {
        String s = "[\n" +
                "    {\n" +
                "        \"actualCapacity\": 3.000,\n" +
                "        \"bizType\": 2,\n" +
                "        \"createTime\": \"2023-06-09T14:28:40\",\n" +
                "        \"delFlag\": 1,\n" +
                "        \"detailId\": \"明细ID\",\n" +
                "        \"id\": 1111111111111111111,\n" +
                "        \"invoice\": \"20074964L66\",\n" +
                "        \"lineType\": 3,\n" +
                "        \"materialCategory\": \"系列酒\",\n" +
                "        \"materialId\": 1665921551753502722,\n" +
                "        \"materialName\": \"qIQxiwtvfuPSkUvxA93nBw==\",\n" +
                "        \"materialNum\": 150.000,\n" +
                "        \"materialSpec\": \"1\",\n" +
                "        \"materialSpecId\": 1665921551954829313,\n" +
                "        \"materialSpecUnit\": \"件\",\n" +
                "        \"materialUnit\": \"件\",\n" +
                "        \"orderId\": 1667056093843345410,\n" +
                "        \"orderSaleType\": 2,\n" +
                "        \"productCode\": \"663271\",\n" +
                "        \"productVolume\": \"0.4500\",\n" +
                "        \"productWeight\": \"450.0000\",\n" +
                "        \"receiveAdrId\": 1666737630058823681,\n" +
                "        \"receiveAdrName\": \"五粮液周边仓-1\",\n" +
                "        \"receiveCusId\": 1661663745663741954,\n" +
                "        \"receiveCusName\": \"码头尖庄仓\",\n" +
                "        \"sendAdrId\": 1666736810374381569,\n" +
                "        \"sendAdrName\": \"五粮液总仓-1\",\n" +
                "        \"sendCusId\": 1661242770195464193,\n" +
                "        \"sendCusName\": \"五粮液总仓\",\n" +
                "        \"updateBy\": 1666722670616428545,\n" +
                "        \"updateTime\": \"2023-06-09T14:45:23\",\n" +
                "        \"updateUser\": \"张飞\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"bizType\": 1,\n" +
                "        \"createBy\": 1658415805700702209,\n" +
                "        \"createTime\": \"2023-05-23T14:47:08\",\n" +
                "        \"createUser\": \"贾昊\",\n" +
                "        \"delFlag\": 1,\n" +
                "        \"id\": 1660900149555630082,\n" +
                "        \"materialCategory\": \"酒\",\n" +
                "        \"materialId\": 5,\n" +
                "        \"materialName\": \"2RkDVfMoKTpRmWE1HLeT8w==\",\n" +
                "        \"materialNum\": 120.000,\n" +
                "        \"materialSpecId\": 7,\n" +
                "        \"materialUnit\": \"件\",\n" +
                "        \"orderId\": 1660900148997787649,\n" +
                "        \"receiveAdrId\": 1660891733492166658,\n" +
                "        \"receiveAdrName\": \"1号供应辅料库出入库\",\n" +
                "        \"receiveCusId\": 1660878946225250306,\n" +
                "        \"receiveCusName\": \"宜宾市叙州区八角枫食品经营部\",\n" +
                "        \"sendAdrId\": 1660891733492166658,\n" +
                "        \"sendAdrName\": \"1号供应辅料库出入库\",\n" +
                "        \"sendCusId\": 1660606753864122370,\n" +
                "        \"sendCusName\": \"504车间\",\n" +
                "        \"updateBy\": 1658415805700702209,\n" +
                "        \"updateTime\": \"2023-05-23T14:47:08\",\n" +
                "        \"updateUser\": \"贾昊\"\n" +
                "    }\n" +
                "]";

        List<TbOrderCapacity> tbOrderCapacities = JSONArray.parseArray(s, TbOrderCapacity.class);
        tbOrderCapacityCDCMapper.batchInsert(tbOrderCapacities);
//        List<UserEntity> userEntities = userMapper.selectList(Wrappers.<UserEntity>lambdaQuery());
//        System.out.println(userEntities);
        return "suss";
    }
}
